<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Category layered navigation
 *
 * @see Mage_Catalog_Block_Layer_View
 */

if($this->canShowBlock()):
if( !defined('ACCORDION_SNYDERPLACE') ){
	define('ACCORDION_SNYDERPLACE', 1);
	?>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery.cookie.min.js') ?>"></script>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery.accordion_snyderplace.js') ?>"></script>
<?php } ?>

<script type="text/javascript">
    $jsmart(document).ready(function($) {
		//syntax highlighter
		//accordion
		$('.layered-accordion').accordion_snyderplace({
			defaultOpen: 'content_la1',
			cookieName: 'layered_accordion',
			speed: 'fast',
			animateOpen: function (elem, opts) { //replace the standard slideUp with custom function
				elem.next().slideFadeToggle(opts.speed);
			},
			animateClose: function (elem, opts) { //replace the standard slideDown with custom function
				elem.next().slideFadeToggle(opts.speed);
			}
		});
		//custom animation for open/close
		$.fn.slideFadeToggle = function(speed, easing, callback) {
			return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
		};
    });
</script>

<div class="layered-nav">
	<div class="block-content-layered block-left">
		<?php echo $this->getStateHtml() ?>
		<?php if ($this->getLayer()->getState()->getFilters()): ?>
		<div class="actions">
			<a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?>
			</a>
		</div>
		<?php endif; ?>
		<?php if($this->canShowOptions()): ?>
		<dl id="narrow-by-list">
			<?php $_filters = $this->getFilters();
			$i_la = 0;
			foreach ( $_filters as $_filter ):
			if( $_filter->getItemsCount() ): ?>
			<div class="block block-shopby-<?php echo $i_la; ?>">
				<dt id="content_la<?php echo $i_la; ?>"
					class="layered-accordion subhead block-title">
					<span><?php echo $this->__($_filter->getName()); ?> </span> <span
						class="accordion-down"></span> <span class="accordion-up"></span>
					<a class="toggle" title="" href="#">&nbsp;</a>
				</dt>
				<div class="block-content">
					<dd>
						<?php echo $_filter->getHtml() ?>
					</dd>
				</div>
			</div>
			<?php endif; 
			$i_la ++;
			endforeach; ?>
		</dl>
		<script type="text/javascript">decorateDataList('narrow-by-list')</script>
		<?php endif; ?>
	</div>
</div>
<?php endif; ?>
